<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{names.title}</title>
    </h:head>
    <h:body rendered="#{!auth.loggedIn}">
        <ui:include src="login.xhtml" />
    </h:body>
    
    <h:body rendered="#{auth.loggedIn}">
        <h:form id="edit_person">
            <h:outputStylesheet library="css" name="style.css"  />
            <h:panelGroup layout="block" class="wrapper">
                <p:panel id="admin_panel" header="#{names.title}" style="margin-bottom:10px;">       
                    <ui:include src="header.xhtml" /> 
                    <p:panel id="edit_person_panel" header="#{names.personEditPanelName}" style="margin-bottom:10px;" styleClass="small">
                        <h:panelGrid columns="3">
                            <p:outputLabel for="firstName" value="#{names.personAttributeFirstName}" />
                            <p:inputText id="firstName" value="#{persons.current.firstName}" required="true" requiredMessage="#{names.personAttributeFirstNameMsg}"/>  
                            <p:message for="firstName" />  
                            <p:outputLabel for="lastName" value="#{names.personAttributeLastName}" />
                            <p:inputText id="lastName" value="#{persons.current.lastName}" required="true" requiredMessage="#{names.personAttributeLastNameMsg}"/>  
                            <p:message for="lastName" />                                
                            <p:outputLabel for="identityCardNumber" value="#{names.personAttributeIdCardNumber}" />
                            <p:inputText id="identityCardNumber" value="#{persons.current.identityCardNumber}" required="true" requiredMessage="#{names.personAttributeIdCardNumberMsg}"/>  
                            <p:message for="identityCardNumber" />                       
                        </h:panelGrid>  
                    </p:panel>


                    <p:panel id="match_persons_panel" header="#{names.pickListPanelName}">
                        <p:pickList id="pickList" value="#{roomPickList.data}" var="room" itemLabel="#{room}" itemValue="#{room}"
                                    showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" converter="roomConverter"
                                    style="margin: 0 auto" >
                            <f:facet name="sourceCaption"><p:outputLabel value="#{names.pickListSource}"/></f:facet>  
                            <f:facet name="targetCaption"><p:outputLabel value="#{names.pickListTarget}"/></f:facet>
                            <p:column>#{room.building} - #{room.name}</p:column> 
                        </p:pickList>
                    </p:panel>


                    <p:panel id="buttons" style="margin-top:10px;">
                        <h:panelGrid columns="3" style="margin: 0 auto">
                            <p:commandButton id="submit" icon="ui-icon-disk" value="#{names.buttonSubmit}" ajax="false" action="#{persons.edit}"/>
                            <p:button icon="ui-icon-close" outcome="showPerson" value="#{names.buttonAbort}"  />  
                            <p:commandButton id="deleteButton" icon="ui-icon-minus" value="#{names.buttonDelete}" onclick="confirmation.show()" type="button" />
                            <p:confirmDialog id="confirmDialog" message="#{names.personDeleteConfirmBody}"  
                                    header="#{names.personDeleteConfirmHeader}" severity="alert" widgetVar="confirmation">  
                                <p:commandButton id="confirm" icon="ui-icon-check" value="#{names.buttonYes}" onclick="confirmation.hide()" action="#{persons.gotoDelete}">
                                </p:commandButton>
                                <p:commandButton id="decline" icon="ui-icon-close" value="#{names.buttonNo}" onclick="confirmation.hide()" type="button" />   
                            </p:confirmDialog> 
                        </h:panelGrid>
                    </p:panel>

                </p:panel>
            </h:panelGroup>
        </h:form>
    </h:body>
</html>
